package com.czl.module_activity.adapter

import android.os.Bundle
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.czl.base.binding.command.BindingCommand
import com.czl.base.binding.command.BindingConsumer
import com.czl.base.config.AppConstants
import com.czl.base.data.bean.ActivityProfileListBean
import com.czl.base.data.bean.NoticeResponseBean
import com.czl.module_activity.R
import com.czl.module_activity.databinding.ItemBulletinBinding
import com.czl.module_activity.databinding.ItemMyActivityBinding
import com.czl.module_activity.fragment.BulletinListFragment
import com.czl.module_activity.fragment.MyActivityFragment

class BulletinAdapter(private val fragment: BulletinListFragment) :
    BaseQuickAdapter<NoticeResponseBean.Record, BaseDataBindingHolder<ItemBulletinBinding>>(
        R.layout.item_bulletin
    ) {
    override fun convert(
        holder: BaseDataBindingHolder<ItemBulletinBinding>,
        item: NoticeResponseBean.Record
    ) {

        holder.dataBinding?.apply {
            data = item
            adapter = this@BulletinAdapter
            executePendingBindings()
        }
    }
    fun getType(type:Int):String{
        return when(type){
            1->"物业公告"
            2->"便民服务"
            3->"版本更新"
            else->""
        }
    }
    val onItemClick: BindingCommand<Any> = BindingCommand(BindingConsumer {
        if (it is NoticeResponseBean.Record){
            fragment.startContainerActivity(
                AppConstants.Router.Activities.F_ACTIVITIES_BULLENTIN_DETAIL,
                Bundle().apply {
                    putInt(
                        AppConstants.BundleKey.BULLENTIN_ID,
                        it.id
                    )
                })
        }
    })
}